package com.company.common.api.wrap.store;

import com.company.cloud.common.redis.service.RedisUtils;

import cn.hutool.core.util.StrUtil;

public class RedisWrapStore implements WrapStore{
	
	private RedisUtils redisUtils;
	
	public RedisWrapStore(RedisUtils redisUtils) {
		this.redisUtils=redisUtils;
		
	}
	


	@Override
	public void putSign(String appSecret, long timestamp, String nonce, String signature, Long time) {
		String key=this.getSignCacheKey(appSecret,timestamp,nonce);
		redisUtils.set(key, signature, time);
		
		
	}

	@Override
	public String getSign(String appSecret, long timestamp, String nonce) {
		String key=this.getSignCacheKey(appSecret,timestamp,nonce);
		return redisUtils.get(key);
	}

	
	private String getSignCacheKey(String appSecret, long timestamp, String nonce) {
		return StrUtil.format("Api:Wrap:Sign:{}:{}:{}", appSecret,timestamp,nonce);
		
		
	}
	
	

}
